package com.ql.controller.yk;

import com.alibaba.fastjson.JSON;
import com.ql.pojo.yk.PageResult;
import com.ql.pojo.yk.Yaopin;
import com.ql.service.yk.YaopinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class YaopinController {
    @Autowired
    private YaopinService yaopinService;

    @RequestMapping("/selectYaopin")
    public ModelAndView selectAll(Integer currpage,Integer rows,Integer status){
        if(currpage==null || currpage ==0){
            currpage=1;
        }
        if(rows==null || rows==0){
            rows=2;
        }
        PageResult page = yaopinService.findPage(currpage,rows);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("page",page);
        modelAndView.addObject("fenye",currpage);
        if(null == status) {
            modelAndView.setViewName("User_management");
        }else{
            modelAndView.setViewName("User_management2");
        }
        return modelAndView;
    }
}
